﻿using BarcodeDelay.FrameDecoder;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace BarcodeDelay.FrameServer
{
    public class MsgMultiThreadHandler
    {
        private static MsgMultiThreadHandler instance;
        public static MsgMultiThreadHandler Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new MsgMultiThreadHandler();
                }
                return instance;
            }
        }

        private MsgMultiThreadHandler()
        {
        }

        public void HandleRawCommand(FrameMessage command)
        {
            if (command == null || command.Session == null || command.Content == null)
            {
                return;
            }

            ThreadPool.QueueUserWorkItem(new WaitCallback(SendToDecode), command);
        }

        private void SendToDecode(Object message)
        {
            FrameDecoderManager.Instance.DecodeMessageFrame(message);
        }
        //////////////////////////////////////////////////////////////////////////End Of Class
    }
}
